#pragma once

#include "Serializable.h"
#include "Vectors.h"

class Team;
class ServiceProvider;

class AuctionManager : public Serializable
{
	friend class GameManager;

public:

	struct Bet
	{

		Bet() : m_team(0), m_player(0), m_bid(0) {}
		Bet(Team* i_team, Player* i_player, size_t i_bid)
			:
			m_team(i_team),
			m_player(i_player),
			m_bid(i_bid)
			{}

		Team*			m_team;
		Player*			m_player;
		size_t			m_bid;

		typedef std::vector<Bet> BetCollection;
		typedef std::vector<Bet>::iterator BetCollectionIt;
		typedef std::vector<Bet>::const_iterator BetCollectionCIt;
	};

	bool Bidding(const Bet& i_bet);
	void Dispatch(const bool i_doNotPrompt);
	void Clear();
	void CreateNewMarket(const size_t i_numberOfNewPlayers);
	const PlayerVec& GetMarket() const;

	virtual	ZStream&	Serialize(ZStream& o_stream);
	virtual ZStream&	Deserialize(ZStream& i_stream);
	
private:

	explicit AuctionManager(ServiceProvider* i_sp);

	AuctionManager(const AuctionManager&);
	AuctionManager& operator=(const AuctionManager&);

	Bet::BetCollection	m_bets;
	ServiceProvider* m_sp;

	PlayerVec m_marketPlayers;
};

inline const PlayerVec& AuctionManager::GetMarket() const
{
	return m_marketPlayers;
}
